package com.guohengspace.mq.config;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @ClassName LogCondition
 * @Description
 * @Author GuanNing
 * @Date 2023/1/6 11:10
 */
public class LogCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        Environment environment = context.getEnvironment();
        String isOpen = environment.getProperty("guohengspace.logging.requestLog.switch");
        // 就算没有设置systemLog.isOpen，那么isOpen就等于null，Boolean.valueOf对于null照样会返回false的
        return Boolean.valueOf(isOpen);
    }
}
